package com.xrui.ftp;

import org.apache.commons.configuration.Configuration;

import java.util.regex.Pattern;

public class FtpConfiguration {

    // Common settings
    //
    public final String host;
    public final String username;
    public final String password;
    public final boolean useActive;
    public final int maxRetries;
    public final int retryWaitMilliseconds;

    // Divergent (Full vs Incremental) settings
    //
    public final String remoteDir;
    public final Pattern listFilterPattern;

    public FtpConfiguration(Configuration config) {
        Configuration c = config.subset("ftpConfig");
        host  = c.getString("host");
        username = c.getString("username");
        password = c.getString("password");
        useActive = c.getBoolean("useActive");
        maxRetries = c.getInt("maxRetries");
        retryWaitMilliseconds = c.getInt("retryWaitMilliseconds");

        remoteDir = c.getString("remoteDir");
        listFilterPattern = Pattern.compile(c.getString("listFilterPattern", ".*"));
    }
}
